package demo.bean;

import java.time.LocalDateTime;
import java.util.concurrent.Future;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;


@Service
public class AsyncBean  {
	
	@Async
	public void doNoResult(){
        try {
            Thread.sleep(1000);
            System.out.println("AsyncBean.doNoResult done" + LocalDateTime.now());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
	
	
	@Async
    public Future<String> doHasResult(){
		String str = "start="+LocalDateTime.now();
        try {
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
		str = str + ",done="+LocalDateTime.now();

        return new AsyncResult<String>(str);
    }
	
}
